package com.ckzp.ext.drawing;


import cn.hutool.core.util.StrUtil;
import com.ckzp.core.ConfigUtil;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.text.DecimalFormat;

import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
import javax.imageio.stream.ImageOutputStream;


/**
 * Created by 51594 on 2024/5/29.
 */
public class DrawingUtils {


    private static float jPEGcompression = 10.75f;// 图片清晰比率


    public static void doGenerateImg(DrawingModel dm) throws Exception {
        if (dm.getDraw_types() == 9 || dm.getDraw_types() == 10) {
            generateZtNewImg(dm);
        } else if (dm.getImg_div11() != null && dm.getImg_div11().length() > 5) {
            generateImg20200513More(dm);
        } else {
            generateImg20200513(dm);
        }
    }


    public static void doGenerateKuaiIndexShareImg(DrawingModel dm) throws Exception {
        // 加载原图图片
        BufferedImage Base = ImageIO.read(new File(dm.getImg_base()));
        // 加载用户的二维码
        BufferedImage ImgDiv1 = readBufferedImage(dm.getImg_div1());
        // 以原图片为模板
        Graphics2D g = Base.createGraphics();
        AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setComposite(ac);
        g.setBackground(Color.WHITE);
        // 写二维码
        if (ImgDiv1 != null) g.drawImage(ImgDiv1, 186, 1027, 190, 190, null);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        saveAsJPEG(Base, out);
        out.close();
        InputStream is = parse(out);
        FileOutputStream fos = new FileOutputStream(dm.getOut_img());
        byte[] b = new byte[1024];
        while ((is.read(b)) != -1) {
            fos.write(b);// 写入数据
        }
        is.close();
        fos.close();// 保存数据
    }


    public static void doGenerateKuaiBizInviteImg(DrawingModel dm) throws Exception {
        // 加载原图图片
        BufferedImage Base = ImageIO.read(new File(dm.getImg_base()));
        // 加载用户的二维码
        BufferedImage ImgDiv1 = readBufferedImage(dm.getImg_div1());
        // 以原图片为模板
        Graphics2D g = Base.createGraphics();
        AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setComposite(ac);
        g.setBackground(Color.WHITE);
        // 写二维码
        if (ImgDiv1 != null) g.drawImage(ImgDiv1, 241, 860, 272, 272, null);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        saveAsJPEG(Base, out);
        out.close();
        InputStream is = parse(out);

        FileOutputStream fos = new FileOutputStream(dm.getOut_img());
        byte[] b = new byte[1024];
        while ((is.read(b)) != -1) {
            fos.write(b);// 写入数据
        }
        is.close();
        fos.close();// 保存数据
    }


    /**
     * @return : java.lang.String
     * @Description : 将二维码图片和文字生成到一张图片上
     * @Param : oldImg 原图
     * @Param : qrCodeImg 二维码地址
     * @Param : shareDesc 图片文字
     * @Author : houzhenghai
     * @Date : 2018/8/15
     */
    public static void generateImg(DrawingModel dm) throws Exception {
        // 加载原图图片
        BufferedImage Base = ImageIO.read(new File(dm.getImg_base()));
        BufferedImage ImgDiv1 = readBufferedImage(dm.getImg_div1());
        BufferedImage ImgDiv2 = readBufferedImage(dm.getImg_div2());
        // 加载用户的二维码
        BufferedImage ImgDiv3 = readBufferedImage(dm.getImg_div3());
        BufferedImage ImgDiv4 = readBufferedImage(dm.getImg_div4());
        // 以原图片为模板
        Graphics2D g = Base.createGraphics();
        AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setComposite(ac);
        g.setBackground(Color.WHITE);
        // 写商品图
        if (ImgDiv1 != null) g.drawImage(ImgDiv1, 0, 0, 800, 800, null);
        // 盖模板
        if (ImgDiv2 != null) g.drawImage(ImgDiv2, 0, 0, 800, 1100, null);
        if (ImgDiv3 != null) g.drawImage(ImgDiv3, 545, 829, 205, 205, null);
        if (ImgDiv4 != null) g.drawImage(ImgDiv4, 42, 825, 133, 42, null);
        //写卖价
        g.setFont(new Font("Akrobat Bold", Font.PLAIN, 82));
        g.setColor(new Color(255, 255, 255));
        g.drawString(dm.getTitle1(), 170, 752);
        //写原价
        g.setFont(new Font("Akrobat Bold", Font.PLAIN, 28));
        g.setColor(hex2Rgb("ff002a"));
        g.drawString(dm.getTitle2(), 116, 790);
        //券价
        int l = dm.getTitle3().length();
        int lefts = 123 + (3 - l) * 20;
        g.setFont(new Font("Akrobat Regular", Font.PLAIN, 86));
        g.setColor(new Color(199, 34, 86));
        g.drawString(dm.getTitle3(), lefts, 1055);

        //主标题
        g.setFont(new Font("Source Han Sans CN Medium", Font.PLAIN, 34));
        g.setColor(new Color(32, 32, 32));
        g.drawString(dm.getTitle4(), 42, 911);
        //副 标题
        g.setFont(new Font("Source Han Sans CN Regular", Font.PLAIN, 24));
        g.setColor(new Color(178, 106, 130));
        g.drawString(dm.getTitle5(), 42, 950);

        //广告词
        l = dm.getTitle6().length();
        lefts = 434 + (9 - l) * 20;
        g.setFont(new Font("Source Han Sans CN Medium", Font.PLAIN, 38));
        g.setColor(Color.white);
        g.drawString(dm.getTitle6(), lefts, 765);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        saveAsJPEG(Base, out);
        out.close();
        InputStream is = parse(out);
        FileOutputStream fos = new FileOutputStream(dm.getOut_img());
        byte[] b = new byte[1024];
        while ((is.read(b)) != -1) {
            fos.write(b);// 写入数据
        }
        is.close();
        fos.close();// 保存数据
    }


    /**
     * @return : java.lang.String
     * @Description : 将二维码图片和文字生成到一张图片上
     * @Param : oldImg 原图
     * @Param : qrCodeImg 二维码地址
     * @Param : shareDesc 图片文字
     * @Author : houzhenghai
     * @Date : 2018/8/15
     */
    public static void drawGcwSharePic(DrawingModel dm) throws Exception {
        // 加载原图图片
        BufferedImage Base = ImageIO.read(new File(dm.getImg_base()));
        // 加载用户的二维码
        BufferedImage ImgDiv1 = readBufferedImage(dm.getImg_div1());
        // 以原图片为模板
        Graphics2D g = Base.createGraphics();
        AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setComposite(ac);
        g.setBackground(Color.WHITE);
        if (ImgDiv1 != null) g.drawImage(ImgDiv1, 168, 721, 415, 415, null);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        saveAsJPEG(Base, out);
        out.close();
        InputStream is = parse(out);
        FileOutputStream fos = new FileOutputStream(dm.getOut_img());
        byte[] b = new byte[1024];
        while ((is.read(b)) != -1) {
            fos.write(b);// 写入数据
        }
        is.close();
        fos.close();// 保存数据
    }


    /**
     * @return : java.lang.String
     * @Description : 将二维码图片和文字生成到一张图片上
     * @Param : oldImg 原图
     * @Param : qrCodeImg 二维码地址
     * @Param : shareDesc 图片文字
     * @Author : houzhenghai
     * @Date : 2018/8/15
     */
    public static void generateImg20200513More(DrawingModel dm) throws Exception {
        // 加载原图图片
        BufferedImage Base = ImageIO.read(new File(getSingle2BasePath() + "v2/base1.png"));
        BufferedImage ImgDiv1 = readBufferedImage(dm.getImg_div1());
        BufferedImage ImgDiv11 = readBufferedImage(dm.getImg_div11());
        BufferedImage ImgDiv12 = readBufferedImage(dm.getImg_div12());
        BufferedImage ImgDiv13 = readBufferedImage(dm.getImg_div13());
        BufferedImage ImgDiv2 = readBufferedImage(getSingle2BasePath() + "v2/adv1.png");
        // 加载用户的二维码
        BufferedImage ImgDiv3 = readBufferedImage(dm.getImg_div3());
        BufferedImage ImgDiv4 = readBufferedImage(dm.getImg_div4());
        // 以原图片为模板
        Graphics2D g = Base.createGraphics();
        AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setComposite(ac);
        g.setBackground(Color.WHITE);
        // 写商品图
        if (ImgDiv1 != null) g.drawImage(ImgDiv1, 31, 117, 688, 688, null);
        if (ImgDiv11 != null) g.drawImage(ImgDiv11, 31, 825, 218, 218, null);
        if (ImgDiv12 != null) g.drawImage(ImgDiv12, 265, 825, 218, 218, null);
        if (ImgDiv13 != null) g.drawImage(ImgDiv13, 501, 825, 218, 218, null);
        // 盖模板
        if (ImgDiv2 != null) g.drawImage(ImgDiv2, 0, 0, 750, 1334, null);//通用模板
        if (ImgDiv3 != null) g.drawImage(ImgDiv3, 555, 1093, 143, 143, null);//2维码
        if (ImgDiv4 != null) g.drawImage(ImgDiv4, 42, 1075, 133, 42, null);//天猫标记
        //写卖价
        g.setFont(new Font("Source Han Sans CN Medium", Font.PLAIN, 52));
        g.setColor(new Color(255, 0, 52));
        g.drawString(dm.getTitle1(), 134, 1222);
        //写原价
        g.setFont(new Font("SourceHanSansCN-Normal", Font.PLAIN, 24));
        g.setColor(new Color(54, 54, 54));
        g.drawString(dm.getTitle2(), 392, 1220);
        //券价
        int l = dm.getTitle3().length();
        int lefts = 174 + (3 - l) * 20;
        g.setFont(new Font("Source Han Sans CN Medium", Font.PLAIN, 20));
        g.setColor(new Color(255, 255, 255));
        g.drawString(dm.getTitle3(), 194, 1285);

        //主标题
        g.setFont(new Font("Source Han Sans CN Medium", Font.PLAIN, 34));
        g.setColor(new Color(54, 54, 54));
        g.drawString(dm.getTitle4(), 32, 1150);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        saveAsJPEG(Base, out);
        out.close();
        InputStream is = parse(out);
        FileOutputStream fos = new FileOutputStream(dm.getOut_img());
        byte[] b = new byte[1024];
        while ((is.read(b)) != -1) {
            fos.write(b);// 写入数据
        }
        is.close();
        fos.close();// 保存数据
        // System.out.println("upt------------------" + dm.getOut_img());

    }


    /**
     * @return : java.lang.String
     * @Description : 将二维码图片和文字生成到一张图片上
     * @Param : oldImg 原图
     * @Param : qrCodeImg 二维码地址
     * @Param : shareDesc 图片文字
     * @Author : houzhenghai
     * @Date : 2018/8/15
     */
    public static void generateImg20200513(DrawingModel dm) throws Exception {
        // 加载原图图片
        BufferedImage Base = ImageIO.read(new File(getSingle2BasePath() + "v2/base.png"));
        BufferedImage ImgDiv1 = readBufferedImage(dm.getImg_div1());
        BufferedImage ImgDiv2 = readBufferedImage(getSingle2BasePath() + "v2/adv.png");
        // 加载用户的二维码
        BufferedImage ImgDiv3 = readBufferedImage(dm.getImg_div3());
        BufferedImage ImgDiv4 = readBufferedImage(dm.getImg_div4());
        // 以原图片为模板
        Graphics2D g = Base.createGraphics();
        AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setComposite(ac);
        g.setBackground(Color.WHITE);
        // 写商品图
        if (ImgDiv1 != null) g.drawImage(ImgDiv1, 31, 117, 688, 688, null);
        // 盖模板
        if (ImgDiv2 != null) g.drawImage(ImgDiv2, 0, 0, 750, 1130, null);
        if (ImgDiv3 != null) g.drawImage(ImgDiv3, 555, 867, 143, 143, null);//2维码
        if (ImgDiv4 != null) g.drawImage(ImgDiv4, 42, 825, 133, 42, null);
        //写卖价
        g.setFont(new Font("Source Han Sans CN Medium", Font.PLAIN, 52));
        g.setColor(new Color(255, 0, 52));
        g.drawString(dm.getTitle1(), 134, 996);
        //写原价
        g.setFont(new Font("SourceHanSansCN-Normal", Font.PLAIN, 24));
        g.setColor(new Color(54, 54, 54));
        g.drawString(dm.getTitle2(), 392, 994);
        //券价
        int l = dm.getTitle3().length();
        int lefts = 174 + (3 - l) * 20;
        g.setFont(new Font("Source Han Sans CN Medium", Font.PLAIN, 20));
        g.setColor(new Color(255, 255, 255));
        g.drawString(dm.getTitle3(), 194, 1059);

        //主标题
        g.setFont(new Font("Source Han Sans CN Medium", Font.PLAIN, 34));
        g.setColor(new Color(54, 54, 54));
        g.drawString(dm.getTitle4(), 32, 924);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        saveAsJPEG(Base, out);
        out.close();
        InputStream is = parse(out);
        FileOutputStream fos = new FileOutputStream(dm.getOut_img());
        byte[] b = new byte[1024];
        while ((is.read(b)) != -1) {
            fos.write(b);// 写入数据
        }
        is.close();
        fos.close();// 保存数据
        System.out.println("upt------------------" + dm.getOut_img());
    }

    public static void generateZtImg(DrawingModel dm) throws Exception {
        // 加载原图图片
        BufferedImage Base = ImageIO.read(new File(dm.getImg_base()));
        BufferedImage ImgDiv1 = readBufferedImage(dm.getImg_div1());
        // BufferedImage ImgDiv2 = readBufferedImage(dm.getImg_div2());
        // 加载用户的二维码
        BufferedImage ImgDiv3 = readBufferedImage(dm.getImg_div3());
        //BufferedImage ImgDiv4 = readBufferedImage(dm.getImg_div4());
        // 以原图片为模板
        Graphics2D g = Base.createGraphics();
        AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setComposite(ac);
        g.setBackground(Color.WHITE);
        // 写商品图
        if (ImgDiv1 != null) g.drawImage(ImgDiv1, 0, 0, 800, 1100, null);
        // 盖模板
        //if (ImgDiv2 != null) g.drawImage(ImgDiv2, 0, 0, 800, 1100, null);
        if (ImgDiv3 != null) g.drawImage(ImgDiv3, 545, 829, 205, 205, null);
        //if (ImgDiv4 != null) g.drawImage(ImgDiv4, 42, 825, 133, 42, null);
//        //写卖价
//        g.setFont(new Font("Akrobat Bold", Font.PLAIN, 82));
//        g.setColor(new Color(255, 240, 0));
//        g.drawString(dm.getTitle1(), 170, 752);
//        //写原价
//        g.setFont(new Font("Akrobat Bold", Font.PLAIN, 28));
//        g.setColor(new Color(255, 241, 206));
//        g.drawString(dm.getTitle2(), 116, 790);
//        //券价
//        int l = dm.getTitle3().length();
//        int lefts = 123 + (3 - l) * 20;
//        g.setFont(new Font("Akrobat Regular", Font.PLAIN, 86));
//        g.setColor(new Color(255, 100, 9));
//        g.drawString(dm.getTitle3(), lefts, 1055);
//
//        //主标题
//        g.setFont(new Font("Source Han Sans CN Medium", Font.PLAIN, 34));
//        g.setColor(new Color(0, 63, 210));
//        g.drawString(dm.getTitle4(), 42, 911);
//        //副 标题
//        g.setFont(new Font("Source Han Sans CN Regular", Font.PLAIN, 24));
//        g.setColor(new Color(57, 57, 57));
//        g.drawString(dm.getTitle5(), 42, 950);

//        //广告词
//        l = dm.getTitle6().length();
//        lefts = 434 + (9 - l) * 20;
//        g.setFont(new Font("Source Han Sans CN Medium", Font.PLAIN, 38));
//        g.setColor(Color.white);
//        g.drawString(dm.getTitle6(), lefts, 765);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        saveAsJPEG(Base, out);
        out.close();
        InputStream is = parse(out);
        FileOutputStream fos = new FileOutputStream(dm.getOut_img());
        byte[] b = new byte[1024];
        while ((is.read(b)) != -1) {
            fos.write(b);// 写入数据
        }
        is.close();
        fos.close();// 保存数据
    }


    public static void generateZtNewImg(DrawingModel dm) throws Exception {
        // 加载原图图片
        BufferedImage Base = ImageIO.read(new File(dm.getImg_base()));
        BufferedImage ImgDiv1 = readBufferedImage(dm.getImg_div1());
        // 加载用户的二维码
        BufferedImage ImgDiv3 = readBufferedImage(dm.getImg_div3());
        // 以原图片为模板
        Graphics2D g = Base.createGraphics();
        AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setComposite(ac);
        g.setBackground(Color.WHITE);
        // 写商品图
        if (ImgDiv1 != null) g.drawImage(ImgDiv1, 0, 0, 750, 1334, null);
        // 盖模板
        // if (ImgDiv3 != null) g.drawImage(ImgDiv3, 504, 720, 210, 210, null);
        if (ImgDiv3 != null) g.drawImage(ImgDiv3, 546, 1068, 160, 160, null);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        saveAsJPEG(Base, out);
        out.close();
        InputStream is = parse(out);
        FileOutputStream fos = new FileOutputStream(dm.getOut_img());
        byte[] b = new byte[1024];
        while ((is.read(b)) != -1) {
            fos.write(b);// 写入数据
        }
        is.close();
        fos.close();// 保存数据
    }

    /**
     * 转换
     *
     * @param out
     * @return
     * @throws Exception
     */
    public static InputStream parse(ByteArrayOutputStream out) throws Exception {
        byte[] buff = out.toByteArray();
        ByteArrayInputStream bin = new ByteArrayInputStream(buff);
        DataInputStream dis = new DataInputStream(bin);
        return dis;
    }

    /**
     * 以JPEG编码保存图片
     *
     * @param imageToSave 要处理的图像图片
     * @param fos         文件输出流
     * @throws IOException
     */
    public static void saveAsJPEG(BufferedImage imageToSave, ByteArrayOutputStream fos) throws IOException {
        ImageWriter imageWriter = ImageIO.getImageWritersBySuffix("jpg").next();
        ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
        imageWriter.setOutput(ios);
        if (jPEGcompression >= 0 && jPEGcompression <= 1f) {
            JPEGImageWriteParam jpegParams = (JPEGImageWriteParam) imageWriter.getDefaultWriteParam();
            jpegParams.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT);
            jpegParams.setCompressionQuality(jPEGcompression);
        }
        ImageIO.setUseCache(false);
        imageWriter.write(new IIOImage(imageToSave, null, null));
        ios.close();
        imageWriter.dispose();
    }

    public static Font[] getSystemFont() {
        Font[] fonts = GraphicsEnvironment
                .getLocalGraphicsEnvironment().getAllFonts();
        return fonts;
    }


    private static Font getFont() {
        try {
            Font font = Font.createFont(Font.TRUETYPE_FONT, new File("/data/kk/font/SourceHanSansCN-Medium.otf"));
            font.deriveFont(Font.PLAIN);
            font.deriveFont(34);
            return font;
        } catch (Exception e) {
            e.printStackTrace();
            return new Font("微软雅黑", Font.PLAIN + Font.BOLD, 16);
        }
    }

    public static BufferedImage readBufferedImage(String img) {
        try {
            return ImageIO.read(new File(img));
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * test
     *
     * @param args
     * @throws
     */
    public static void main(String[] args) {
        long starttime = System.currentTimeMillis();
        System.out.println("开始：" + starttime);
        try {
            DrawingModel dm = DrawingModel.n();
            dm.setImg_base("/data/kk/base.jpg");//底图
            dm.setImg_div1("/data/kk/goods.jpg");//商品图
            dm.setImg_div2("/data/kk/1.png");//框图
            dm.setImg_div3("/data/kk/qr.jpg");//2维码
            dm.setImg_div4("/data/kk/tm.png");//2维码

            dm.setTitle1("¥288");
            dm.setTitle2("¥1998");
            dm.setTitle3("200");
            dm.setTitle4("商品主标题共九个字十四个字");
            dm.setTitle5("商副村题差不多可以写二十个字主标题共九个");
            dm.setTitle6("广告词不超过九个字");

            dm.setOut_img("/data/bstuan/jiao/out.jpg");

            DrawingUtils.generateImg(dm);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("结束：" + (System.currentTimeMillis() - starttime) / 1000);

        Font f = getFont();
        f.deriveFont(Font.PLAIN);
        f.deriveFont(34L);
        System.out.println(f.getFamily());
    }

    /**
     * @param colorStr
     * @return
     */
    public static Color hex2Rgb(String colorStr) {
        return new Color(
                Integer.valueOf(colorStr.substring(1, 3), 16),
                Integer.valueOf(colorStr.substring(3, 5), 16),
                Integer.valueOf(colorStr.substring(5, 7), 16));
    }

    private static String getSingle2BasePath() {
        if (ConfigUtil.isLinux()) {
            return "/data/kk/";
        } else {
            return "d:/wuyang/temp/";
        }
    }
}
